home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17414 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: yama.mcc.ac.uk!dmu!usenet
  2. From: Christopher Pilsworth <hcm94cp@dmu.ac.uk>
  3. Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++,dmu.lang.c++
  4. Subject: STL input iterators
  5. Date: Mon, 15 Apr 1996 19:54:53 -0700
  6. Organization: DeMontfort University
  7. Message-ID: <31730BFD.12E@dmu.ac.uk>
  8. NNTP-Posting-Host: mkcsug17.mk.dmu.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win16; I)
  13. CC: hcm94cp@dmu.ac.uk
  14.  
  15. Hi there,
  16.  
  17. I am looking for someone who can help me with some STL stuff.
  18. I have checked out a lot of the web/ftp sites for relevant code but have 
  19. so far been unable to find any.
  20.  
  21. I bought a book the other day that showed how to use input and output 
  22. iterators to write containers (the example was a vector) to disk.  It 
  23. looked extremely simple.  However the compiler didn't like it.  
  24.  
  25. The method seems to work with a standard ostream or istream (cin/cout) 
  26. but did not work when given a ifstream or ofstream as in the book.
  27.  
  28. I need this code urgently as it seems the best way to manage indexes to 
  29. my data files and the deadline is in two weeks time.
  30.  
  31. The code in the book looked kind of like this:
  32.  
  33.  
  34.  
  35. ifstream myin ("infile");
  36. ofstream myout("outfile);
  37.  
  38. istream_iterator<char> input_iter(myin), eos;
  39. ostream_iterator<char> output_iter(myout);
  40.  
  41. vector<char> myvector ...etc. etc.
  42. ... 
  43. (This is probably wrong but is there just to give the jist)
  44.  
  45. The problem was on the third line of code. The error message was "illegal 
  46. template arguments".  I have checked over and over that the text was 
  47. identical to that of the book, but still no joy!
  48.  
  49. Does the STL supplied with the Metrowerks Codewarrior 8 not like fstreams 
  50. as arguments to this template.
  51.  
  52. I'm sorry that I can not supply my code as I am in university and the 
  53. code is at home.  Any hints on making containers persistent (any way) 
  54. would be very gratefully recieved.
  55.  
  56. thankyou in advance
  57.  
  58. regards
  59.  
  60. Christopher Pilsworth
  61. HCM94CP@dmu.ac.uk
  62. PS: Please could replies be CC'd to the above e-mail address as I 
  63. sometimes have problems with my news reader. Thanks
  64.